﻿using Ldt.DataEngine.DataFlowParse.Model;
using LdtJudge.DataEngine.Model.Collection;
using LdtJudge.DataEngine.Model.Personnel;
using LdtJudge.DataEngine.Model.XMLConfigModel.DataStores;
using LdtJudge.DataEngine.Model.XMLConfigModel.OptimizeConfigModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Xml;

namespace LdtJudge.DataEngine.DataBaseStores
{
    /// <summary>
    /// 系统配置数据层
    /// </summary>
    public class DataLayerSysStores
    {

        ///<summary>
        /// 系统配置内容xml
        ///</summary> 
        private Dictionary<string, XmlDocument> SysConfigXml = new Dictionary<string, XmlDocument>();
        /// <summary>
        /// 系统配置内容table
        /// </summary>
        private Dictionary<string, DataTable> SysConfigTab = new Dictionary<string, DataTable>();
        /// <summary>
        /// <summary>
        /// 系统配置内容ConfigModel
        /// </summary>
        private Dictionary<string, ConfigModel> SysConfigModel = new Dictionary<string, ConfigModel>();

        /// <summary>
        /// 提取人员对话信息的配置
        /// </summary>
        public List<ParagraphAnalysisFactListItem> paragraphAnalysisFactListItems { get; set; }

        /// <summary>
        /// 案由要素定位配置
        /// </summary>
        public List<DOCLocationModel> locationModelList { get; set; }

        /// <summary>
        /// 优选/同节点合并配置
        /// </summary>
        public OptimizeFactConfig optimizeFactConfig { get; set; }

        /// <summary>
        /// 证据内容信息
        /// </summary>
        public Dictionary<string, List<DataModel>> dicEviden = new Dictionary<string, List<DataModel>>();

        /// <summary>
        /// 根据key获取指定内容,不存在返回null
        /// </summary>
        /// <param name="keyName"></param>
        public XmlDocument GetConfigXml(string keyName)
        {
            if (SysConfigXml.ContainsKey(keyName))
            {
                return SysConfigXml[keyName];
            }
            return null;
        }

        /// <summary>
        /// 向系统配置中添加数据内容，如果存在覆盖
        /// </summary>
        /// <param name="keyName">key</param>
        /// <param name="data">内容</param>
        /// <returns></returns>
        public void SetConfigXml(string keyName,XmlDocument data)
        {
            SysConfigXml[keyName] = data;
        }

        /// <summary>
        /// 根据key获取指定内容,不存在返回null
        /// </summary>
        /// <param name="keyName"></param>
        public DataTable GetConfigTab(string keyName)
        {
            if (SysConfigTab.ContainsKey(keyName))
            {
                return SysConfigTab[keyName];
            }
            return null;
        }
        
        /// <summary>
        /// 向系统配置中添加数据内容，如果存在覆盖
        /// </summary>
        /// <param name="keyName">key</param>
        /// <param name="data">内容</param>
        /// <returns></returns>
        public void SetConfigTab(string keyName, DataTable data)
        {
            SysConfigTab[keyName] = data;
        }

        /// <summary>
        /// 根据key获取指定内容,不存在返回null
        /// </summary>
        /// <param name="keyName"></param>
        public ConfigModel GetConfigModel(string keyName)
        {
            if (SysConfigModel.ContainsKey(keyName))
            {
                return SysConfigModel[keyName];
            }
            return null;
        }

        /// <summary>
        /// 向系统配置中添加数据内容，如果存在覆盖
        /// </summary>
        /// <param name="keyName">key</param>
        /// <param name="data">内容</param>
        /// <returns></returns>
        public void SetConfigModel(string keyName, ConfigModel data)
        {
            SysConfigModel[keyName] = data;
        }
    }
}
